package com.acmedcare.framework.exchange.center.core.resolve;


import com.acmedcare.framework.exchange.center.entity.dto.Hdfs;

public class PathResolveFactory {


  private final Hdfs hdfs;

  public PathResolveFactory(Hdfs hdfs) {
    this.hdfs = hdfs;
  }

  public IPathResolve getPathResolve(String uri,String rootPath) {

    if (uri.toLowerCase().startsWith("http")) {

      return new WGetPathResolve(uri, rootPath);
    } else if (uri.toLowerCase().startsWith("hdfs")) {

      return new HdfsReslove(uri, rootPath, hdfs);
    } else if (uri.toLowerCase().startsWith("/")) {

      return new LocalFileResolve(uri, rootPath);
    }

    return new DefaultPathResolve(uri);
  }

  public IPathResolve getPathResolve(String uri, String name,String  rootPath) {

    if (uri.toLowerCase().startsWith("http")) {

      return new WGetPathResolve(uri, name,rootPath);
    } else if (uri.toLowerCase().startsWith("hdfs")) {

      return new HdfsReslove(uri, name, rootPath, hdfs);
    } else if (uri.toLowerCase().startsWith("/")) {

      return new LocalFileResolve(uri, name, rootPath);
    }

    return new DefaultPathResolve(uri);
  }
}